//
//  HttpServerResponse.cpp
//  myhttpserver
//
//  Created by tgy on 2018/3/21.
//  Copyright © 2018年 tgy. All rights reserved.
//

#include "HttpServerResponse.hpp"
#include <sstream>

void HttpserverResponse::setMessage(std::string message){
    
    this->message = message;
}

void HttpserverResponse::setHttpVersion(std::string httpVersion){
    
    this->httpVersion = httpVersion;
}

void HttpserverResponse::setBody(std::string body){
    
    this->body = body;
}

std::string HttpserverResponse::getSendMessage(){
    
    std::ostringstream oss;
    
    oss << httpVersion << " "<< stauts << " "<< message << "\r\n";
    for (std::map<std::string, std::string>::iterator  p = heads.begin(); p != heads.end() ; p++) {
        
        oss << p->first << ": " << p->second<<"\r\n";
    }
    
    if (body.size() > 0) {
        
        oss <<"\r\n\r\n"<< body;
    }
    
    return oss.str();
}
